package scheduler;

import java.util.concurrent.LinkedBlockingQueue;


public class FrontEnd {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int nbArgs = args.length;
		boolean remoteWorker = false;
		if (nbArgs == 5){
			remoteWorker = true; 
		}
		int port=0; 
		int nbLocalWorker = 0; 
		port = Integer.parseInt(args[1]);
		nbLocalWorker = Integer.parseInt(args[3]);
		LinkedBlockingQueue<Task> linkedQueue = new LinkedBlockingQueue<Task>(nbLocalWorker);
		LinkedBlockingQueue<Task> done = new LinkedBlockingQueue<Task>();
		
		LocalWorker localWorker = new LocalWorker(nbLocalWorker, linkedQueue, done);
		Scheduler scheduler = new Scheduler(port, linkedQueue, done);
		
		Thread threadScheduler =  new Thread(scheduler);
		Thread threadWorker = new Thread(localWorker);
		threadScheduler.start();
		threadWorker.start();
		try {
			threadScheduler.join();
			threadWorker.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		
	}

}
